package com.arthur.service;

import com.arthur.entity.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept findById(Long id) {
                Dept dept=new Dept();
                dept.setDeptno(id);
                dept.setDname("由于该"+id+"没有对应的信息，Consumer客户端已进行了服务降级处理，Provider服务端已关闭了此服务");
                dept.setDbsource("数据库没有资源");
                return dept;
            }

            @Override
            public List<Dept> findAll() {
                return null;
            }
        };
    }
}
